package com.benmei.ntlive.common;

/**
 * Created by Peter on 2018/10/15.
 */
public enum UserRole {
    student(1, "学生"),
    teacher(2, "老师");

    private final Integer code;

    private final String name;



    UserRole(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }


    public static UserRole getByCode(Integer code) {
        UserRole result = null;
        for (UserRole userRole : UserRole.values()) {
            if (userRole.code.intValue() ==code.intValue()) {
                result = userRole;
                break;
            }
        }
        return result;
    }

    public static boolean contains(Integer code) {
        boolean result = false;
        for (UserRole userRole : UserRole.values()) {
            if (userRole.code.intValue()==code.intValue()) {
                result = true;
                break;
            }
        }
        return result;
    }
}
